const arr = [1, 2, 3, 4, 5];
const obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };

for (let i in arr) {
  console.log(i);
}

console.log('----------------');

for (let i in obj) {
  console.log(i);
}
console.log('----------------');

for (let i of arr) {
  console.log(i);
}
console.log('----------------');

/* 
    不可遍历对象(对象默认是不可迭代的)
*/

for (let [key, value] of Object.entries(obj)) {
  console.log(key, value);
}
